package List;

public class ReverseList206 {
    public ListNode reverseList(ListNode head){
        if(head == null){
            return head;
        }
        ListNode pre = null;
        ListNode cur = head;
        ListNode temp = null;
        while(cur != null){
            temp = cur.next;// 保存下一个节点
            cur.next = pre;
            pre = cur;
            cur = temp;
        }
        return pre;
    }
}
